package com.lemonsama.lesson4;

import javax.swing.*;
import java.awt.*;

public class IconTest extends JFrame implements Icon {

    private int width;
    private int height;

    public IconTest() {}

    public IconTest(int width, int height) {
        this.width = width;
        this.height = height;
    }

    public void init() {
        IconTest iconTest = new IconTest(15, 15);
        JLabel jLabel = new JLabel("IconTest", iconTest, SwingConstants.CENTER);
        Container contentPane = this.getContentPane();
        contentPane.add(jLabel);
        this.setVisible(true);
        this.setBounds(100, 100, 300, 300);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new IconTest().init();
    }

    @Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        g.fillOval(x, y, this.width, this.height);
    }

    @Override
    public int getIconWidth() {
        return this.width;
    }

    @Override
    public int getIconHeight() {
        return this.height;
    }
}
